import sys
import os
import random
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *

class Demo(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parent = parent
        layout = QVBoxLayout()
        layout.setAlignment(Qt.AlignmentFlag.AlignTop)
        toolBar=QToolBar()

        '''toolBar.addWidget(QLabel('CustomColor:'))
        self.custom=QLineEdit()
        #self.custom.setText('#ffff00')
        toolBar.addWidget(self.custom)
'''
        toolBar.addWidget(QLabel("Option:"))        
        self.optonCombox=QComboBox()
        self.optonCombox.addItems(QFontDialog.FontDialogOption.__members__.keys())        
        toolBar.addWidget(self.optonCombox)

        btn=QPushButton('ShowFontDialog')
        btn.clicked.connect(self.OnShowDialog)
        toolBar.addWidget(btn)

        layout.addWidget(toolBar)

        self.label=QLabel('Hello 测试字体选择')     
        layout.addWidget(self.label)  

        self.setLayout(layout)
    def OnShowDialog(self):
        dialog=QFontDialog()        
        option=QFontDialog.FontDialogOption[self.optonCombox.currentText()]
        ok,font= dialog.getFont(self.label.font(),self,'Select Font',option)        
        if ok:
            self.label.setFont(font)
            self.parent.OnShowMessage(f'Selected Font:{font.toString()}')
def runDemo(parent):
    wigdet =  Demo(parent)
    return wigdet